import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Choice;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JMenu;
import javax.swing.JComboBox;


public class SearchPatientGUI extends JPanel {
    private JTextField textField;
    int location;
    String userS;
    User user;
    List<User> users;
    public SearchPatientGUI() {
        setLayout(null);
        
        final JComboBox comboBox = new JComboBox();
        comboBox.setBounds(172, 47, 138, 23);
        add(comboBox);
        
        
        textField = new JTextField();
        textField.setBounds(109, 14, 247, 22);
        add(textField);
        textField.setColumns(10);
        
        JButton btnCancel = new JButton("Cancel");
        btnCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                location = -1;
            }
        });
        btnCancel.setBounds(10, 266, 89, 23);
        add(btnCancel);
        
        JButton btnEdit = new JButton("Search");
        btnEdit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                userS = textField.getText();
                location = 3;
               for( int i = 0; i < users.size(); i++)
               {
                   comboBox.insertItemAt(users.get(i).getSSN(), i);
               }
               
            }
        });
        btnEdit.setBounds(10, 14, 89, 23);
        add(btnEdit);
        
        JButton button_1 = new JButton("Basic info");
        button_1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                user = (User) comboBox.getSelectedItem();
                location = 20;
            }
        });
        button_1.setBounds(10, 47, 138, 23);
        add(button_1);
        
        JButton button_3 = new JButton("Treatment Record");
        button_3.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
               user = (User) comboBox.getSelectedItem();
               location = 6;
            }
        });
        button_3.setBounds(10, 81, 138, 23);
        add(button_3);
    }
    
    public int getLoc()
    {
        return location;
    }
    public void setLoc(int i)
    {
        location = i;
    }
    //public String getSearch()
    //{
    //    return search;
    //}
    public void setUsers(List<User> input)
    {
        users = input;
    }
    
    public String getUser()
    {
        return userS;
    }
    
    public User getUsern(){
        return user;
    }
}
